package com.eazyshop.search.controller;

import com.eazyshop.common.pojo.Result;


import com.eazyshop.search.service.ESservice;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


@RestController
@CrossOrigin
public class SkuController {

    @Autowired
    private ESservice eSservice;

   public  Result createMappingAndIndex(){
       eSservice.createMappingAndIndex();
       return new Result("创建索引成功");
   }
    /**
     * 导入全部数据
     * @return
     */
   public Result  importAll(){
        eSservice.importAll();
        return new Result("导入全部数据成功");
   }
    /**
     * 根据spuID导入对应的所有sku数据到
     * es对应的索引库中
     */

    public Result importSkuBySpuId( String id){
            eSservice.importDataBySpuId(id);
            return new Result("导入成功");
   }

    public void deleteGoodsBySpuId(String spuId){
        eSservice.deleteGoodsBySpuId(spuId);
    }

}
